<template>
  <basic-container :btnFlag=true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>

      <el-collapse v-model="activeNames"
                   @change="handleChange"
                   style="margin-top:2rem;">
        <el-collapse-item name="1">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">规划信息</div>
            </div>
          </template>
          <div style="float: right;
                      font-size: 18px;
                      text-align: center;
                      margin-right: 51px;"
               v-if="pmuc">
            <span>规划编码：</span>
            <span style="display: inline-block">{{pmuc}}</span>
          </div>
          <div class="searchDetail">
            <bostech-detail :detail-data="detailData"></bostech-detail>
          </div>
        </el-collapse-item>
        <el-collapse-item name="2">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">版本信息</div>
            </div>
          </template>
          <edition-list :achievementId="achievementId"
                        @haveDataFlag="editionHaveDataMethod"></edition-list>
        </el-collapse-item>
        <el-collapse-item name="3">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">征求意见信息</div>
            </div>
          </template>
          <opinion-list :relateId="achievementId"
                        :type='3'
                        @haveDataFlag="opinionHaveDataMethod"></opinion-list>
        </el-collapse-item>
      </el-collapse>
      <div class="form-submit">
        <el-button type="info"
                   size="small"
                   @click.stop="goBack()">关闭</el-button>
      </div>
    </div>
  </basic-container>
</template>
<script>
import { PROJECT_DIC } from '@/const/dict'
import { projectDetail } from "@/api/planning/project";
import { resultDetail } from "@/api/planning/result";
import getDetailData from "@/mixins/getDetailData";
import { mapGetters } from "vuex"
import { getfileinfopage } from "@/api/system";
import opinionList from "@/views/opinion/opinionList";
import editionList from "@/views/make/editionList";
export default {
  name: "opinionDetail",
  mixins: [getDetailData()],
  components: {
    opinionList,
    editionList
  },
  watch: {

  },
  data () {
    return {
      headerData: {
        title: '征求意见详情'
      },
      achievementId: '',//成果ID
      reviewHaveDataFlag: true,// 审批列表是否显示标志
      pmuc: '',// 规划编码
      activeNames: ["1", "2", "3"],
      detailData: [],
    };
  },
  created () {
    this.achievementId = this.$route.params.id
    this.getDetailData();
  },
  computed: mapGetters([
    "userInfo"
  ]),
  methods: {
    goBack () {
      this.$router.go(-1);
    },
    handleChange (val) {
    },
    // 获取详情信息
    getDetailData () {
      resultDetail(this.$route.params.id).then(response => {
        this.getresultDetail(response);
      })
    },
    async  getresultDetail (response) {
      if (response.data.code == '0') {
        var records = response.data.data
        if (records.fileId != "" && records.fileId != null) {
          this.multiplefiles = [];
          this.multiplefiles = await this.getfileinfopagetemp(records);
        }
        this.pmuc = records.pmuc
        this.getresultDetailDate(records)
        if (records.registerinfoId) {
          this.getReisterInfo(records.registerinfoId)
        }
      }
    },
    getfileinfopagetemp (records) {
      return new Promise((resolve, reject) => {
        if (records.fileId != "" && records.fileId != null) {
          getfileinfopage(Object.assign({
            current: 1,
            size: 100,
            fileIds: records.fileId
          })).then(response => {
            var multiplefiles = response.data.data.records;
            resolve(multiplefiles);
          }).catch(
          )
        }
      })

    },
    // 获取规划
    getReisterInfo (id) {
      projectDetail(id).then(response => {
        if (response.data.code == '0') {
          var records = response.data.data
          if (records.registerinfoTopicVOList.length > 0) {
            this.msgFlag = true
            for (var i in records.registerinfoTopicVOList) {
              this.getMessage(records.registerinfoTopicVOList[i], i);
            }
          }
        }
      })
    },
    opinionHaveDataMethod () { },
    editionHaveDataMethod () { }
  }
};
</script>
<style lang="scss" scoped>
</style>
